<?php
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('index', 'prod', true);
sfContext::createInstance($configuration);


// Remove the following lines if you don't use the database layer
$databaseManager = new sfDatabaseManager($configuration);
$databaseManager->loadConfiguration();


$uploadToDirBase = "/home/meteenee/domains/meteenee.com/public_html/pikun";


//Your email at Google Picasa.
$username = "ad@xcodecartoon.com";


//Your password here.
$pass = "35700011";



$c = new Criteria();
$c->add(PhotoPeer::ISPICASA, 0);
$c->addAscendingOrderByColumn(PhotoPeer::ID);
$c->setLimit(10);

$photos = PhotoPeer::doSelect($c);
foreach($photos as $photo){

	$filename = $uploadToDirBase.$photo->getUrl();
	
	$temp = explode("/", $photo->getUrl());
	
	$photoName = array_pop($temp);
	$photoTags = NULL;
	
	$picasa = new PicasaUploader($username, $pass);
	$picasa->upload($filename, $photoName, $photoTags);
	$imageContent = $picasa->getContent();
	
	$photo->setIspicasa(1);
	$photo->setPicasaurl($imageContent->getSrc());
	
	echo "\nSrc = ".$imageContent->getSrc()."\n";
	
	$photo->save();
	
}